package ouc.pkere.utils.generator.entity;

import java.io.File;

public class DbSqlModuleConfigMetaData {

    private String INTELLIJ_IDEA_PROJECT_SRC_PATH_PREFIX
            = "src" + File.separator + "main" + File.separator + "java" + File.separator;
    private String moduleId;
    private String moduleNickname; // 模块显示名，中文
    private String moduleName; // 模块名，用于生成模块中各类的名字

    private String moduleEntityClassName; // Entity类名
    private String moduleRepositoryClassName; // Repository类名
    private String moduleServiceClassName; // Service类名
    private String moduleViewControllerClassName; // 视图控制器类名
    private String moduleRestControllerClassName; // Rest控制器类名

    private String moduleEntityClassNameWithSuffix; // Entity类名.java
    private String moduleRepositoryClassNameWithSuffix; // Repository类名.java
    private String moduleServiceClassNameWithSuffix; // Service类名.java
    private String moduleViewControllerClassNameWithSuffix; // 视图控制器类名.java
    private String moduleRestControllerClassNameWithSuffix; // Rest控制器类名.java

    private String modulePkg;
    private String moduleUrl;
    private String moduleTable;
    private String moduleDescription;
    private String moduleStatus;

    private String modulePath;

    public DbSqlModuleConfigMetaData() {

    }

    public String getModuleId() {
        return moduleId;
    }

    public void setModuleId(String moduleId) {
        this.moduleId = moduleId;
    }

    public String getModuleName() {
        return moduleName;
    }

    public void setModuleName(String moduleName) {
        this.moduleName = moduleName;
        this.moduleEntityClassName = moduleName + "Entity";
        this.moduleRepositoryClassName = moduleName + "Repository";
        this.moduleServiceClassName = moduleName + "Service";
        this.moduleViewControllerClassName = moduleName + "ViewController";
        this.moduleRestControllerClassName = moduleName + "RestController";

        this.moduleEntityClassNameWithSuffix = moduleName + "Entity.java";
        this.moduleRepositoryClassNameWithSuffix = moduleName + "Repository.java";
        this.moduleServiceClassNameWithSuffix = moduleName + "Service.java";
        this.moduleViewControllerClassNameWithSuffix = moduleName + "ViewController.java";
        this.moduleRestControllerClassNameWithSuffix = moduleName + "RestController.java";
    }

    public String getModuleEntityClassName() {
        return moduleEntityClassName;
    }

    public String getModuleRepositoryClassName() {
        return moduleRepositoryClassName;
    }

    public String getModuleServiceClassName() {
        return moduleServiceClassName;
    }

    public String getModuleViewControllerClassName() {
        return moduleViewControllerClassName;
    }

    public String getModuleRestControllerClassName() {
        return moduleRestControllerClassName;
    }

    public String getModulePkg() {
        return modulePkg;
    }

    public void setModulePkg(String modulePkg) {
        this.modulePkg = modulePkg;

        // 获取当前工程路径
        String projectPath = System.getProperty("user.dir");

        // 将包路径分割成路径字符串数组
        String[] modulePkgSplit = modulePkg.split("\\.");

        // 构造模块的绝对路径字符串
        this.modulePath = projectPath + File.separator;
        this.modulePath = this.modulePath + INTELLIJ_IDEA_PROJECT_SRC_PATH_PREFIX;

        for (int i = 0; i < modulePkgSplit.length; i++) {

            // 最后一个路径后不添加路径分隔符
            if (i == (modulePkgSplit.length - 1)) {
                this.modulePath = this.modulePath + modulePkgSplit[i];
            } else {
                this.modulePath = this.modulePath + modulePkgSplit[i] + File.separator;
            }
        }

        //System.out.println(this.modulePath);
    }

    public String getModulePath() {
        return modulePath;
    }

    public String getModuleUrl() {
        return moduleUrl;
    }

    public void setModuleUrl(String moduleUrl) {
        this.moduleUrl = moduleUrl;
    }

    public String getModuleTable() {
        return moduleTable;
    }

    public void setModuleTable(String moduleTable) {
        this.moduleTable = moduleTable;
    }

    public String getModuleDescription() {
        return moduleDescription;
    }

    public void setModuleDescription(String moduleDescription) {
        this.moduleDescription = moduleDescription;
    }

    public String getModuleStatus() {
        return moduleStatus;
    }

    public void setModuleStatus(String moduleStatus) {
        this.moduleStatus = moduleStatus;
    }

    public String getModuleNickame() {
        return moduleNickname;
    }

    public void setModuleNickname(String moduleNickname) {
        this.moduleNickname = moduleNickname;
    }


    public String getModuleEntityClassNameWithSuffix() {
        return moduleEntityClassNameWithSuffix;
    }

    public String getModuleRepositoryClassNameWithSuffix() {
        return moduleRepositoryClassNameWithSuffix;
    }

    public String getModuleServiceClassNameWithSuffix() {
        return moduleServiceClassNameWithSuffix;
    }

    public String getModuleViewControllerClassNameWithSuffix() {
        return moduleViewControllerClassNameWithSuffix;
    }

    public String getModuleRestControllerClassNameWithSuffix() {
        return moduleRestControllerClassNameWithSuffix;
    }

    /**
     * 测试函数
     *
     * @param args
     */
    public static void main(String[] args) {
        new DbSqlModuleConfigMetaData().setModulePkg("ouc.ns.mtp.testmodule");
    }
}
